﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KraveDAL;

public partial class uploadPhoto : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        if (FileUpload1.PostedFile != null)
        {
            string extension = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);

            if (extension.Equals(".jpg"))
            {
                String filename = FileUpload1.PostedFile.FileName;
                string url = "C:\\Users\\Muhammad Irfan\\Documents\\Visual Studio 2010\\.net project\\images\\" + filename;
                FileUpload1.PostedFile.SaveAs(url);

                ReservationDAL rd = new ReservationDAL();
              
                int id = Convert.ToInt32(TextBox1.Text);
                
                
                if (rd.SavePhoto(id,url))
                {
                    Response.Redirect("adminViewEvent.aspx");
                }
            }
            else
            {
                Response.Redirect("erropage.aspx");
            }
        }
    }
}